<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    function a(fn, params) {
        if (typeof fn != 'function') {
            return
        }
        let obj = {}
        let params1 = Array.from(arguments).slice(1)
        obj.__proto__ = fn.prototype
        let res = fn.call(obj, ...params1)
        console.log(params1)
    }

    function func1(name) {
        this.name = name
    }

    let b = a(func1, '11')

    class person {
        constructor() {
            this.name = 'xxx'
        }
        a () {

        }
    }

    class son extends person {
        constructor() {
            super()
        }
    }

    let obj2 = {
        name: '1',
        age: '2'
    }
    let obj3 = JSON.parse(JSON.stringify(obj2))
    obj2.age = '4'
    console.log(obj3)

    function clone(target) {
        if (typeof target == 'object') {
            let obj = Array.isArray(target) ? [] : {}
            for (let key in target) {
                obj[key] = clone(target[key])
            }
            return obj
        } else {
            return target
        }
    }

    let obj11 = {
        name: 'xx',
        age: '11',
        func: function () {
            console.log('321')
        },
        obj: {
            color: 'red'
        },
        arr: [1,2,{cc: '33'}]
    }

    let obj22 = clone(obj11)
    obj11.obj.color = 'blue'
    obj11.arr[2].cc = '44'
    console.log(obj11)
    console.log(obj22)
</script>
</html>